package com.sky.ok.controller;

import com.sky.ok.entity.Person;
import com.sky.ok.service.PersonS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 余心乐sky
 * @create 2018-11-02 12:48
 **/
@RestController
public class PersonC {
  /*  @Autowired
    JdbcTemplate jdbcTemplate;

    @Autowired
    private PersonS personS;
    //增加
    @PostMapping(value="/person")
    public int savePerson(@RequestParam("id") Integer id,@RequestParam("age") Integer age,@RequestParam("name") String name){
        return personS.savePerson(id,age,name);
    }
    //访问
    @GetMapping(value="/person/{id}")
    public Person getPerson(@PathVariable("id") Integer id){
        return personS.getPerson(id);
    }
    //修改
    @PutMapping(value="/person/{id}")
    public int updatePerson(@PathVariable("id") Integer id,@RequestParam("age") Integer age,@RequestParam("name") String name){
        return personS.updatePerson(id,age,name);
    }
    //删除
    @DeleteMapping(value="/person/{id}")
    public int deletePerson(@PathVariable("id")Integer id){
        return personS.deletePerson(id);
    }

    //访问(template测试)
    @GetMapping(value="/ok/{id}")
    public List<Person> getTest(@PathVariable("id") Integer id){

        return jdbcTemplate.query("select * from base where id = "+id,new BeanPropertyRowMapper(Person.class) );
    }*/
}